﻿// Project: Salient
// http://salient.codeplex.com
// 
// Copyright 2010, Sky Sanders <sky at skysanders.net>
// Dual licensed under the MIT or GPL Version 2 licenses.
// http://salient.codeplex.com/license
// 
// Date: April 25 2010 

#region

using System;
using System.Data;

#endregion

namespace Salient.Web.UserFiles
{
    ///<summary>
    ///</summary>
    public class EntryInfo
    {
        ///<summary>
        ///</summary>
        public EntryInfo()
        {
            CreationTimeUtc = LastWriteTimeUtc = DateTime.Now.ToUniversalTime();
            EntryId = Guid.NewGuid();
        }

        ///<summary>
        ///</summary>
        ///<param name="reader"></param>
        public EntryInfo(IDataRecord reader)
        {
            EntryId = reader.GetValueOrDefault<Guid>("EntryId");
            Path = reader.GetValueOrDefault<string>("Path");
            CreationTimeUtc = reader.GetValueOrDefault<DateTime>("CreationTimeUtc");
            LastWriteTimeUtc = reader.GetValueOrDefault<DateTime>("LastWriteTimeUtc");
            ParentEntryId = reader.GetValueOrDefault<Guid?>("ParentEntryId");
            Data = reader.GetValueOrDefault<byte[]>("Data") ?? new byte[] {};
            IsDirectory = reader.GetValueOrDefault<bool>("IsDirectory");
        }

        ///<summary>
        ///</summary>
        public Guid EntryId { get; set; }
        ///<summary>
        ///</summary>
        public string Path { get; set; }
        ///<summary>
        ///</summary>
        public DateTime CreationTimeUtc { get; set; }
        ///<summary>
        ///</summary>
        public DateTime LastWriteTimeUtc { get; set; }
        ///<summary>
        ///</summary>
        public byte[] Data { get; set; }
        ///<summary>
        ///</summary>
        public Guid? ParentEntryId { get; set; }
        ///<summary>
        ///</summary>
        public EntryInfo[] Children { get; set; }
        ///<summary>
        ///</summary>
        public bool HasChildren { get; set; }
        ///<summary>
        ///</summary>
        public bool IsDirectory { get; set; }
    }
}